@extends('admin::layouts.master')
@section('title')
    会员列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 300px;    ">
                                <input type="text" name="phone" placeholder="手机号码" value="{{$arr_search['phone']}}" autocomplete="off" class="layui-input"></div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small"  onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>

                    <div class="layui-card-body " style="overflow-x: auto;">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>图像</th>
                                <th>用户名</th>
                                <th>会员昵称</th>
                                <th>电子邮箱</th>
                                <th>手机号码</th>
                                <th>性别</th>
                                <th>真实姓名</th>
                                <th>会员生日</th>
                                <th>实时积分</th>
                                <th>累计积分</th>
                                <th>会员等级</th>
                                <th>注册时间</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                            <tr>
                                <td>{{ $value['id'] }}</td>
                                <td>
                                    @if( !empty( $value['head_img']['full_src']) )
                                        <img src="{{ $value['head_img']['full_src'] }}" style="width: 80px;height: 80px;" class="Look_img" title="点击查看大图" >
                                    @endif
                                </td>
                                <td>{{ $value['username'] }}</td>
                                <td>{{ $value['nickname'] }}</td>
                                <td>{{ $value['email'] }}</td>
                                <td>{{ $value['phone'] }}</td>
                                <td>{{ $value['sex_msg'] }}</td>
                                <td>{{ $value['realname'] }}</td>
                                <td>{{ $value['birthday_msg'] }}</td>
                                <td>{{ $value['integral'] }}</td>
                                <td>{{ $value['integral_all'] }}</td>
                                <td>{{ $value['level_name'] }}</td>
                                <td>{{ $value['created_at'] }}</td>
                                <td><input type="checkbox" name="close" data-id="{{$value['id']}}" data-status="{{$value['status']}}" lay-skin="switch" lay-filter="switchTest" @if( $value['status'] == 1 ) checked="" @endif lay-text="启用|禁用"> </td>
                                <td class="td-manage">
                                    <a title="详情" class="layui-btn layui-btn-primary" onclick="parent.xadmin.add_tab('详情','{{route("admin_user_detail",["user_id"=>$value["id"]])}}')" href="javascript:;">
                                        详情
                                    </a>
                                </td>
                            </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif


                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

                //点击图片查看大图
                var bigImgIndex = null;
                $("body").on('click','.Look_img',function(){
                    var img_src = $(this).attr('src');
                    var img_infor = "<img width='500px' height='600px' border='0' src='" + img_src + "' />";
                    bigImgIndex = layer.open({
                        content:img_infor,
                        type:1,
                        area:['auto'],
                        shadeClose: true,
                        shade:[0.4, '#000000'],
                        title:false,
                        closeBtn:true
                    });
                });


                form.on('switch(switchTest)', function(data){
                    var id = $(this).attr('data-id');
                    var status = 1;
                    if( $(this).attr('data-status') == 1 ){
                        status = 2;
                    }
                    $.ajax({
                        url: js_url('admin-user-update'),
                        type: 'post',
                        data: {id:id,status:status,'_token': '{{csrf_token()}}'},
                        dataType: "json",
                        success: function (result) {
                            if (result.state === 0) {
                                    layer.msg(result.msg, {time: 500, icon: 6}, function () {
                                });
                            } else {
                                layer.msg(result.msg, {time: 2000, icon: 5});
                            }
                        }
                    });
                });
               
            })
    </script>
@endsection




